Skip to content

fix: Flaky test with the FeeEstimationQuery e2e test#2276

Merged
aceppaluni merged 8 commits into
hiero-ledger:mainfrom
manishdait:fix/flaky-fee-estimation
May 13, 2026
Merged

fix: Flaky test with the FeeEstimationQuery e2e test#2276
aceppaluni merged 8 commits into
hiero-ledger:mainfrom
manishdait:fix/flaky-fee-estimation

Conversation

@manishdait

Copy link
Copy Markdown
Contributor

Description:
This PR addresses flaky failures in the integration test with FeeEstimateQuery would fail because the FeeEstimationService had not yet started after a fresh Hiero Solo Mirror Node start.

Changes Made:

  • Added wait_for_fee_estimation_service_ready to probe the service using an INTRINSIC mode query. This ensures the service is actually functional before the test suite proceeds.

Related issue(s):

Fixes #2275

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@github-actions github-actions Bot added the scope: flaky test involves tests that are flaky label May 13, 2026
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@manishdait
manishdait force-pushed the fix/flaky-fee-estimation branch from 508b96f to 668efdf Compare May 13, 2026 17:42
@manishdait
manishdait marked this pull request as ready for review May 13, 2026 17:59
@manishdait
manishdait requested review from a team as code owners May 13, 2026 17:59
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Fee estimation query integration tests now wait for the mirror-node FeeEstimationService to become ready before execution. Module-level globals track polling state, a readiness helper probes with an intrinsic fee transaction until success or timeout, and a synchronization helper adds fixed delay. All four test variants invoke these helpers consistently.

Changes

Fee Estimation Readiness Polling

Layer / File(s) Summary
Readiness polling infrastructure and first test update
tests/integration/fee_estimate_query_e2e_test.py
time import and module-level _fee_estimation_ready and _fee_estimation_error globals track polling state. wait_for_fee_estimation_service_ready(env) polls FeeEstimateQuery with an intrinsic fee transaction until it succeeds or times out, raising a stored error. wait_for_sync() adds fixed delay for mirror-node synchronization. The main account-based fee estimate test calls both helpers before creating and following the transaction.
Test readiness updates across remaining variants
tests/integration/fee_estimate_query_e2e_test.py
State-mode account fee estimation, chunked file-append fee estimation, and chunked topic-message fee estimation tests each invoke the readiness and sync helpers before transaction execution, applying the same polling pattern across all test variants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Flaky test with the FeeEstimationQuery e2e test' clearly describes the main change: addressing flaky FeeEstimationQuery integration tests by adding service readiness checks.
Description check ✅ Passed The description is directly related to the changeset, explaining the root cause (FeeEstimationService not ready after fresh node start) and the solution (wait_for_fee_estimation_service_ready helper).
Linked Issues check ✅ Passed The PR fulfills the objective from issue #2275 by implementing a wait-for-service mechanism that ensures FeeEstimationService is ready before tests execute, directly addressing the flakiness during early network startup.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the flakiness issue in FeeEstimateQuery tests. The additions of wait_for_fee_estimation_service_ready and wait_for_sync helpers, plus module-level tracking variables, are all in-scope for addressing intermittent test failures.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration/fee_estimate_query_e2e_test.py (1)

81-83: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Strengthen assertions to validate result structure and content.

All four tests only assert result is not None, which doesn't validate the actual fee estimation response. Integration tests should verify observable network behavior beyond success/failure.

Consider asserting on the result's structure and content:

  • Does result contain fee amounts (node, network, service fees)?
  • Are the returned fees reasonable (positive values, within expected ranges)?
  • For chunked transactions, do the fees reflect the chunk count?
💪 Example of stronger assertions
 query = FeeEstimateQuery().set_transaction(tx)
 result = query.execute(env.client)

 assert result is not None
+assert result.node_fee is not None and result.node_fee.to_tinybars() > 0
+assert result.network_fee is not None and result.network_fee.to_tinybars() > 0
+assert result.service_fee is not None and result.service_fee.to_tinybars() >= 0

(Adjust field names based on actual FeeEstimateQuery result structure)

As per coding guidelines: "Tests must assert observable network behavior, not just SUCCESS" and "Validate resulting balances, ownership, and state changes (not just transaction success)."

Also applies to: 96-98, 112-114, 130-132


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a709e65-3029-40cc-920f-de8516c992bf

📥 Commits

Reviewing files that changed from the base of the PR and between b56df16 and 668efdf.

📒 Files selected for processing (1)
  • tests/integration/fee_estimate_query_e2e_test.py

Comment thread tests/integration/fee_estimate_query_e2e_test.py
Comment thread tests/integration/fee_estimate_query_e2e_test.py
Comment thread tests/integration/fee_estimate_query_e2e_test.py
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels May 13, 2026

@aceppaluni aceppaluni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manishdait Thank you for fixing the flakiness of the tests.

Questions addressed in DM in discord.

@github-actions github-actions Bot added queue:maintainers PR awaiting maintainer final review and removed queue:junior-committer PR awaiting initial quality review labels May 13, 2026

@AntonioCeppellini AntonioCeppellini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :D 🚀

@aceppaluni
aceppaluni merged commit 312db19 into hiero-ledger:main May 13, 2026
25 of 29 checks passed
@manishdait manishdait added this to the v0.2.7 milestone May 14, 2026
NssGourav pushed a commit to NssGourav/hiero-sdk-python that referenced this pull request May 14, 2026
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@manishdait
manishdait deleted the fix/flaky-fee-estimation branch June 5, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open to community review PR is open for community review and feedback queue:maintainers PR awaiting maintainer final review scope: flaky test involves tests that are flaky

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flakiness in FeeEstimateQuery during early network startup

3 participants